$_GET['page'] loading content incorrectly

Posted by s32ialx on Stack Overflow See other posts from Stack Overflow or by s32ialx
Published on 2010-03-31T04:37:27Z Indexed on 2010/03/31 4:43 UTC
Read the original article Hit count: 319

Filed under:
|
|

OK so here is my previous post PHP Templated Site w/ file_get_content links

now i got that issue resolved BUT the problem is now that the content loads it displays UNDER the div i placed #CONTENT# inside so the styles are being ignored and it's posting #CONTENT# outside the divs at positions 0,0 any suggestions? please

© Stack Overflow or respective owner

$_GET['page'] loading content incorrectly

Posted by s32ialx on Stack Overflow See other posts from Stack Overflow or by s32ialx
Published on 2010-03-31T06:37:07Z Indexed on 2010/03/31 6:43 UTC
Read the original article Hit count: 318

Filed under:
|
|
|

OK so here is my previous post PHP Templated Site w/ file_get_content links

now i got that issue resolved BUT the problem is now that the content loads it displays UNDER the div i placed #CONTENT# inside so the styles are being ignored and it's posting #CONTENT# outside the divs at positions 0,0 any suggestions?

Found out whats happening by using "View Source" seems that it's putting all of the #CONTENT#, content that's being loaded in front of the tag.

Like this

<doctype...>
<div class="home">
blah blah
</div>
<head>
<script src=""></script>
</head>
<body>
 <div class="header"></div>
 <div class="contents">
 #CONTENT# < where content SHOULD load
 </div>
 <div class="footer"></div>
</body>

so anyone got a fix?

OK so a better description I'll add relevant screen-shots

Whats happening is /* file.class.php */

<?php

$file = new file();

class file{
    var $path = "templates/clean";
    var $ext = "tpl";

    function loadfile($filename){
  return file_get_contents($this->path . "/" . $filename . "." . $this->ext);
 }

 function css($val,$content='',$contentvar='#CSS#') {
  if(is_array($val)) {
   $css = 'style="';
   foreach($val as $p) {
    $css .= $p . ";";
   }
   $css .= '"';
  } else {
   $css = 'style="' . $val . '"';
  }
  if($content!='') {
   return str_replace($contentvar,' ' . $css,$content);
  } else {
   return $css;
  }
 }

 function setsize($content,$width='-1',$height='-1',$border='-1'){
  $css = '';
  if($width!='-1') { $css = $css . "width=\"".$width."\""; }
  if($height!='-1') { $css = $css . "height=\"".$height."\""; }
  if($border!='-1') { $css = $css . "border=\"" . $border . "\""; }
  return str_replace('#SIZE#',' ' . $css,$content);
 }

 function setcontent($content,$newcontent,$vartoreplace='#CONTENT#'){
  $val = str_replace($vartoreplace,$newcontent,$content);
  return $val;
 }

 function p($content) {
  $v = $content;
  $v = str_replace('#CONTENT#','',$v);
  $v = str_replace('#SIZE#','',$v);
  print $v;
 }
}
if (isset($_GET['page'])) {
 $content = $_GET['page'].'.php'; 
} else {
 $content = 'main.php';
}
?>

is calling for a file_get_contents at the bottom which I use in

/* index.php */

<?php
    include('classes/file.class.php');

    // load the templates
    $header = $file->loadfile('header');
    $body = $file->loadfile('body');
    $footer = $file->loadfile('footer');

    // fill body.tpl #CONTENT# slot with $content
    $body = $file->setcontent($body, $content);

    // cleanup and output the full page
    $file->p($header . $body . $footer);

?>

and loads into

/* body.tpl */

<div id="bodys">
    <div id="bodt"></div>
        <div id="bodm">
            <div id="contents">
                #CONTENT#

                </div>
            </div>
    <div id="bodb"></div>
</div>

but the issue is as follows the $content loads properly img tags etc <h2> tags etc but CSS styling is TOTALY ignored for position width z-index etc. and as follows here's the screen-shot

My Firefox Showing Incorrect Site

JUST incase you require the css for where $content is being loaded

#bodys {
    top:91px;
    position:absolute;
    width:100%;
}
        #bodt {
            margin-left:auto;
            margin-right:auto;
            top:3px;
            position:relative;
            width:820px;
            height:42px;
            background-image:url('images/pagetop.png');
            background-repeat:no-repeat;
            z-index: 0;
        }
        #bodm {
            margin-left:auto;
            margin-right:auto;
            top:3px;
            position:relative;
            width:820px;
            background-image:url('images/pagemid.png');
            background-repeat:repeat-y;
            z-index: 0;
        }
        #bodb {
            margin-left:auto;
            margin-right:auto;
            bottom:-42px;
            position:relative;
            width:820px;
            height:42px;
            background-image:url('images/pagebot.png');
            background-repeat:no-repeat;
            z-index:-1;
        }
#menuo {
    position:absolute;
    bottom:-2px;
    z-index:199;
}
#contents {
    position:relative;
    top:5px;
    left:25px;
    width:770px;
    z-index:10;
    overflow: auto;
    color: #000000;
    line-height: 1.3em;
    font-size: 12px;
}
#content {
    position:absolute;
    top:5px;
    left:25px;
    width:760px;
    z-index:1;
    color: #000000;
    line-height: 1.3em;
    font-size: 12px;
}
#contents p{
    margin-bottom: 0.7em;
}
#contents a{
    font-weight:bold;
    color: #6fa5fd;
    border-bottom: 1px dotted #6fa5fd;
}

© Stack Overflow or respective owner

Related posts about php

Related posts about -get